﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        private string file = "jianli.rtf";

        /// <summary>
        /// load btn
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLoad_Click(object sender, EventArgs e)
        {
            //richTextBox1.LoadFile(file);
            OpenFileDialog openFileDialog=new OpenFileDialog();
            DialogResult dialogResult= openFileDialog.ShowDialog();
            if (dialogResult == DialogResult.OK) {
                richTextBox1.LoadFile(openFileDialog.FileName);
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            //richTextBox1.SaveFile(file);
            SaveFileDialog saveFileDialog=new SaveFileDialog(); 
            DialogResult dialogResult= saveFileDialog.ShowDialog();
            if (dialogResult == DialogResult.OK) { 
             richTextBox1.SaveFile(saveFileDialog.FileName);
            }
        }

        private void btnCopy_Click(object sender, EventArgs e)
        {
            richTextBox1.Copy();
        }

        private void btnCut_Click(object sender, EventArgs e)
        {
            richTextBox1.Cut();
        }

        private void btnPaste_Click(object sender, EventArgs e)
        {
            richTextBox1.Paste();
        }

        private void btnBackColor_Click(object sender, EventArgs e)
        {
            richTextBox1.SelectionBackColor = Color.Yellow;
        }

        private void btnColor_Click(object sender, EventArgs e)
        {
             //richTextBox1.SelectionColor = Color.Blue;
            ColorDialog colorDialog=new ColorDialog();
            DialogResult dialogResult= colorDialog.ShowDialog();
            if (dialogResult == DialogResult.OK) { 
              richTextBox1.SelectionBackColor=colorDialog.Color;
            }
        }

        private void btnFont_Click(object sender, EventArgs e)
        {
            // Font font = new Font("黑体", 20);
            //richTextBox1.SelectionFont = font;
            FontDialog fontDialog = new FontDialog();
            DialogResult dialogResult = fontDialog.ShowDialog();
            if (dialogResult == DialogResult.OK) { 
                      richTextBox1.SelectionFont= fontDialog.Font;
            }
        }
    }
}
